<?php
class Admin_Home_ListTemplate extends AbstractModel{
	public function browse(){
		$db = new AbstractDB();
		$allTemplate = $db->select("str_name,int_using","template");
		$result = array();
		while($row = mysql_fetch_row($allTemplate)){
			$result[] = $row;
		}
		return $result;
	}
	
	public function updateTemplate($data,$where,$templateName){
		//update to db
		$db = new AbstractDB();		
		//reset all template to 0
		$reset = array("int_using"=>0);
		$template = $db->update("template",$reset);
		//update new actived Template
		$template = $db->update("template",$data,$where);
		
		//update to config file
		$sysConf = new SystemConfig();
		$config = $sysConf->getConfig("basic.ini");		
		//set new actived template
		$config["template"]["name"] =  $templateName;		
		$sysConf->saveChangedConfig($config,"basic.ini");
		return 	$config;
	}
}